/*
 * Copyright 2012 Daniel Kurka
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.googlecode.mgwt.examples.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.googlecode.mgwt.dom.client.event.tap.TapEvent;
import com.googlecode.mgwt.dom.client.event.tap.TapHandler;
import com.googlecode.mgwt.mvp.client.Animation;
import com.googlecode.mgwt.ui.client.MGWT;
import com.googlecode.mgwt.ui.client.MGWTSettings;
import com.googlecode.mgwt.ui.client.animation.AnimationHelper;
import com.googlecode.mgwt.ui.client.widget.Button;
import com.googlecode.mgwt.ui.client.widget.LayoutPanel;

public class SimpleAnimationExample implements EntryPoint {

	@Override
	public void onModuleLoad() {
		//set viewport and other settings for mobile
		MGWT.applySettings(MGWTSettings.getAppSetting());

		//build animation helper and attach it
		final AnimationHelper animationHelper = new AnimationHelper();
		RootPanel.get().add(animationHelper);

		//build some UI
		LayoutPanel layoutPanel = new LayoutPanel();
		Button button = new Button();
		button.setText("Animate");

		button.addTapHandler(new TapHandler() {

			@Override
			public void onTap(TapEvent event) {
				//build second ui
				LayoutPanel layoutPanel = new LayoutPanel();
				Button button = new Button();
				button.setText("second");
				layoutPanel.add(button);
				animationHelper.goTo(layoutPanel, Animation.FLIP);

			}
		});

		layoutPanel.add(button);

		//animate
		animationHelper.goTo(layoutPanel, Animation.SLIDE);
	}

}
